try:
  import xbmcgui;
except:
  # For command line testing outside of XBMC
  from FakeXBMCGUI import FakeXBMCGUI;
  xbmcgui = FakeXBMCGUI();

def checkSettings(oSettings):
  # Check the settings in a loop, asking the user to fix any errors found.
  # Allow the user to terminate the loop and stop and continue when the
  # settings are acceptbale. sSourceDevice is set before the loop terminates.
  import os;
  oDialog = xbmcgui.Dialog();
  while 1:
    iMinimalDurationMovie = oSettings.get("minimal-duration-movie");
    iMinimalDurationTVShow = oSettings.get("minimal-duration-tvshow");
    sDestinationPath = oSettings.get("destination-path");
    sMakeMKVConPath = oSettings.get("makemkvcon-path");
    if not iMinimalDurationMovie:
      if not oDialog.yesno(oSettings.sName,
          "The minimal duration for movies is not defined!",
          "Would you like to enter the add-on settings?"):
        return False;
    elif not iMinimalDurationTVShow:
      if not oDialog.yesno(oSettings.sName,
          "The minimal duration for TV shows is not defined!",
          "Would you like to enter the add-on settings?"):
        return False;
    elif not sDestinationPath:
      if not oDialog.yesno(oSettings.sName,
          "The destination folder is not defined!",
          "Would you like to enter the add-on settings?"):
        return False;
    elif not os.path.isdir(sDestinationPath):
      if not oDialog.yesno(oSettings.sName,
          "The destination folder does not exist!",
          "(%s)" % sDestinationPath,
          "Would you like to enter the add-on settings?"):
        return False;
    elif not os.path.isfile(sMakeMKVConPath):
      if not oDialog.yesno(oSettings.sName,
          "The file makemkvcon.exe was not found!",
          "(%s)" % sMakeMKVConPath,
          "Would you like to enter the add-on settings?"):
        return False;
    else:
      return True;
    oSettings.showDialog();
    #loop
